package com.ibiaoke.boss.controller;

import com.ibiaoke.common.response.Res;
import com.ibiaoke.goods.entity.ShopPrice;
import com.ibiaoke.goods.service.ShopPriceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class ShopPriceController {

    @Autowired
    private ShopPriceService shopPriceService;

    /**
     * 添加店铺商品
     * @param shopPrices
     * @return
     */
    @ResponseBody
    @RequestMapping("/batchSaveShopPrice")
    public Res batchSaveShopPrice(@RequestBody List<ShopPrice> shopPrices){
        shopPriceService.batchSaveShopPrice(shopPrices);
        return Res.create();
    }

    /**
     * 查询商品店铺价格和库存
     * @param goodsId
     * @return
     */
    @ResponseBody
    @RequestMapping("/listShopPrice")
    public Res listShopPrice(Integer goodsId) {
        List<ShopPrice> shopPrices = shopPriceService.listShopPrice(goodsId);
        return Res.create().addResponse("shopPrices",shopPrices);
    }
}
